import java.util.Arrays;

public class demo2 {
    public static int[] missingTwo(int[] nums) {
        int sum=0;
        int n=nums.length;
        int []arr=new int[2*n+2];
        for (int i = 0; i <n ; i++) {
            arr[i]=nums[i];
        }
        for(int i=0;i<n;i++){
            sum^=nums[i]^(i+1);
            arr[n+i]=(i+1);
        }
        arr[2*n]=n+1;
        arr[2*n+1]=n+2;
        sum=sum^(n+1)^(n+2);
        int ret1=0;
        int ret2=0;
        for (int i = 0; i <2*n+2 ; i++) {
                sum^=arr[i];
                if(sum==0)ret2=arr[i];
                else{
                    ret1=sum;
                }
        }
        return new int[]{ret1,ret2};
    }

    public static void main(String[] args) {
        int []arr={2,3};
        int[]sum=new int[2];
        sum=missingTwo(arr);
        System.out.println(Arrays.toString(sum));
    }
}
